package ch01.shangji.shangji3;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Person {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Class clz = Class.forName("ch01.shangji.shangji3.JavaBean");

        //获取static final int getAge()方法，没有就用null代替
        Method getSb = clz.getDeclaredMethod("getSb", null);
        //将setAccessable设为可访问
        getSb.setAccessible(true);
        Object returnSb = getSb.invoke(null, null);
        System.out.println("调用值：" + returnSb);
    }
}
